<?php


namespace App\Constants;


use App\Exceptions\ApiException;

class AuthType
{
    /**
     * 邮箱
     */
    const CHECK_EMAIL = 1;
    /**
     * 手机
     */
    const CHECK_PHONE = 2;
    /**
     * 谷歌验证码
     */
    const CHECK_GOOGLE_CAPTCHA = 3;


    public static $lib_check_type = [
        self::CHECK_EMAIL => "手机",
        self::CHECK_PHONE => "邮箱",
        self::CHECK_GOOGLE_CAPTCHA => "谷歌验证码"
    ];

    public static $lib_register_type = [
        self::CHECK_EMAIL => "手机",
        self::CHECK_PHONE => "邮箱",
    ];

    public static function check($v)
    {
        if (!in_array($v, array_keys(self::$lib_check_type))) {
            throw new ApiException('', 421);
        }
    }

    public static function checkRegister($v)
    {
        if (!in_array($v, array_keys(self::$lib_register_type))) {
            throw new ApiException('', 421);
        }
    }

}
